package com.transcendence.appwidget.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.transcendence.appwidget.R;
import com.transcendence.appwidget.adapter.EditAdapter;
import com.transcendence.appwidget.twofive.TwoFiveUpdateBgService;
import com.transcendence.core.global.Global;
import com.transcendence.core.utils.log.LogUtils;
import com.transcendence.core.utils.sp.SPUtils;

/**
 * @author joephone
 * @date 2023/9/21
 * @desc
 */
public class EditActivity extends AppCompatActivity implements EditAdapter.OnItemClickListener {

    private RecyclerView mRv;
    private EditAdapter mAdapter;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edit);
        SPUtils.getInstance().save("goto_edit",false);
//        // 获取窗口对象
//        Window window = getWindow();
//
//        // 设置窗口属性
//        WindowManager.LayoutParams params = window.getAttributes();
//        params.width = WindowManager.LayoutParams.MATCH_PARENT;
//        params.height = getWindowManager().getDefaultDisplay().getHeight();//(int) (getWindowManager().getDefaultDisplay().getHeight() * 0.8);
//        params.gravity = Gravity.BOTTOM; // 将窗口位于底部
//
//        window.setAttributes(params);

        LinearLayoutManager manager = new LinearLayoutManager(this);
        mRv = findViewById(R.id.rv);
        mRv.setLayoutManager(manager);
        mAdapter = new EditAdapter(EditActivity.this);
        mRv.setAdapter(mAdapter);
        mAdapter.setListener(this);
    }

    @Override
    public void onItemClick(int position) {
        LogUtils.d("onItemClick:"+position);
        mAdapter.setSelectPos(position);
        startService(new Intent(EditActivity.this, TwoFiveUpdateBgService.class));
    }
}
